import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/application/emergency/communicate_entity.dart';
import 'package:enterprise_v6_app/app/data/common/tree_node_bean.dart';

import 'package:enterprise_v6_app/app/data/entities/application/emergency/communication_personnel_entity.dart';


CommunicateEntity $CommunicateEntityFromJson(Map<String, dynamic> json) {
  final CommunicateEntity communicateEntity = CommunicateEntity();
  final String? companyCode = jsonConvert.convert<String>(json['companyCode']);
  if (companyCode != null) {
    communicateEntity.companyCode = companyCode;
  }
  final String? createBy = jsonConvert.convert<String>(json['createBy']);
  if (createBy != null) {
    communicateEntity.createBy = createBy;
  }
  final String? createById = jsonConvert.convert<String>(json['createById']);
  if (createById != null) {
    communicateEntity.createById = createById;
  }
  final String? createDate = jsonConvert.convert<String>(json['createDate']);
  if (createDate != null) {
    communicateEntity.createDate = createDate;
  }
  final String? deleted = jsonConvert.convert<String>(json['deleted']);
  if (deleted != null) {
    communicateEntity.deleted = deleted;
  }
  final String? exercisePlanName = jsonConvert.convert<String>(json['exercisePlanName']);
  if (exercisePlanName != null) {
    communicateEntity.exercisePlanName = exercisePlanName;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    communicateEntity.id = id;
  }
  final String? parentId = jsonConvert.convert<String>(json['parentId']);
  if (parentId != null) {
    communicateEntity.parentId = parentId;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    communicateEntity.type = type;
  }
  final String? updateBy = jsonConvert.convert<String>(json['updateBy']);
  if (updateBy != null) {
    communicateEntity.updateBy = updateBy;
  }
  final String? updateById = jsonConvert.convert<String>(json['updateById']);
  if (updateById != null) {
    communicateEntity.updateById = updateById;
  }
  final String? updateDate = jsonConvert.convert<String>(json['updateDate']);
  if (updateDate != null) {
    communicateEntity.updateDate = updateDate;
  }
  final List<CommunicateEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<CommunicateEntity>(e) as CommunicateEntity).toList();
  if (children != null) {
    communicateEntity.children = children;
  }
  final bool? isExpand = jsonConvert.convert<bool>(json['isExpand']);
  if (isExpand != null) {
    communicateEntity.isExpand = isExpand;
  }
  final bool? isSelected = jsonConvert.convert<bool>(json['isSelected']);
  if (isSelected != null) {
    communicateEntity.isSelected = isSelected;
  }
  final List<CommunicationPersonnelEntity>? userList = (json['userList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<CommunicationPersonnelEntity>(e) as CommunicationPersonnelEntity).toList();
  if (userList != null) {
    communicateEntity.userList = userList;
  }
  return communicateEntity;
}

Map<String, dynamic> $CommunicateEntityToJson(CommunicateEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['companyCode'] = entity.companyCode;
  data['createBy'] = entity.createBy;
  data['createById'] = entity.createById;
  data['createDate'] = entity.createDate;
  data['deleted'] = entity.deleted;
  data['exercisePlanName'] = entity.exercisePlanName;
  data['id'] = entity.id;
  data['parentId'] = entity.parentId;
  data['type'] = entity.type;
  data['updateBy'] = entity.updateBy;
  data['updateById'] = entity.updateById;
  data['updateDate'] = entity.updateDate;
  data['children'] = entity.children.map((v) => v.toJson()).toList();
  data['isExpand'] = entity.isExpand;
  data['isSelected'] = entity.isSelected;
  data['userList'] = entity.userList.map((v) => v.toJson()).toList();
  return data;
}

extension CommunicateEntityExtension on CommunicateEntity {
  CommunicateEntity copyWith({
    String? companyCode,
    String? createBy,
    String? createById,
    String? createDate,
    String? deleted,
    String? exercisePlanName,
    String? id,
    String? parentId,
    int? type,
    String? updateBy,
    String? updateById,
    String? updateDate,
    List<CommunicateEntity>? children,
    bool? isExpand,
    bool? isSelected,
    List<CommunicationPersonnelEntity>? userList,
  }) {
    return CommunicateEntity()
      ..companyCode = companyCode ?? this.companyCode
      ..createBy = createBy ?? this.createBy
      ..createById = createById ?? this.createById
      ..createDate = createDate ?? this.createDate
      ..deleted = deleted ?? this.deleted
      ..exercisePlanName = exercisePlanName ?? this.exercisePlanName
      ..id = id ?? this.id
      ..parentId = parentId ?? this.parentId
      ..type = type ?? this.type
      ..updateBy = updateBy ?? this.updateBy
      ..updateById = updateById ?? this.updateById
      ..updateDate = updateDate ?? this.updateDate
      ..children = children ?? this.children
      ..isExpand = isExpand ?? this.isExpand
      ..isSelected = isSelected ?? this.isSelected
      ..userList = userList ?? this.userList;
  }
}
